package
{
	import flash.net.NetStream;
	
	import mx.containers.Canvas;
	import mx.controls.HSlider;
	import mx.controls.Label;
	import mx.controls.Text;
	public class CustomClient
	{
		var ns:NetStream;
		var num:int;
		var f1:Text;
		var myStoryDuration:Array;
		var totaltime:Label;
		var seekSlider:HSlider;
		var duration:Number=0;
		var myStoryDurations:Array;
		var count:int=0;
		var Canvas2SliderLoading:Array;
		var mySliderBar:Canvas;
		
		public function CustomClient(i:int, _ns:NetStream, _f1:Text, _seekSlider:HSlider, _totaltime:Label, _myStoryDuration:Array, _myStoryDurations:Array, _Canvas2SliderLoading:Array, _mySliderBar:Canvas)
		{
			num = i;
			ns = _ns;
			f1 = _f1;
			seekSlider = _seekSlider;
			totaltime = _totaltime;
			myStoryDuration = _myStoryDuration;
			myStoryDurations = _myStoryDurations;
			Canvas2SliderLoading = _Canvas2SliderLoading;
			mySliderBar = _mySliderBar;
		}
		public function onMetaData(item:Object):void 
       	{
       		if(count==0)
	       	{	
	       		duration = Math.floor(item.duration);
    	   		myStoryDurations[num] = duration;
				myStoryDuration[0]+=Math.floor(item.duration);
				seekSlider.value = ns.time;
				seekSlider.minimum = 0;
				seekSlider.maximum = myStoryDuration[0];
				totaltime.text = myStoryDuration[0].toString();
				count++;
				var totalDur:int = 0;
				
		//		for(var j=0; j<Canvas2SliderLoading.length; j++) {	totalDur+=myStoryDurations[j];	}
					
				for(var i=0; i<Canvas2SliderLoading.length; i++)
				{
					var tmp:int = 0;	
			//		Canvas2SliderLoading[i].width = 30;//(myStoryDurations[i]/myStoryDuration[0])*mySliderBar.width;
					for(var j=0; j<i; j++) 
					{	tmp+=myStoryDurations[j];	}
					
					Canvas2SliderLoading[i].x = tmp/myStoryDuration[0]*mySliderBar.width;
				}
	       	}
       	}
	
	}
	
	
}